<?php

/**
 * This is the model class for table "food_package".
 *
 * The followings are the available columns in table 'food_package':
 * @property integer $id
 * @property integer $food_quantity
 * @property string $price
 * @property integer $reservation_details_id
 * @property integer $branch_has_menu_package_id
 *
 * The followings are the available model relations:
 * @property ReservationDetails $reservationDetails
 * @property BranchHasMenuPackage $branchHasMenuPackage
 */
class FoodPackage extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return FoodPackage the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'food_package';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('food_quantity, price, reservation_details_id, branch_has_menu_package_id', 'required'),
			array('food_quantity, reservation_details_id, branch_has_menu_package_id', 'numerical', 'integerOnly'=>true),
			array('price', 'length', 'max'=>11),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, food_quantity, price, reservation_details_id, branch_has_menu_package_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'reservationDetails' => array(self::BELONGS_TO, 'ReservationDetails', 'reservation_details_id'),
			'branchHasMenuPackage' => array(self::BELONGS_TO, 'BranchHasMenuPackage', 'branch_has_menu_package_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'food_quantity' => 'Food Quantity',
			'price' => 'Price',
			'reservation_details_id' => 'Reservation Details',
			'branch_has_menu_package_id' => 'Branch Has Menu Package',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('food_quantity',$this->food_quantity);
		$criteria->compare('price',$this->price,true);
		$criteria->compare('reservation_details_id',$this->reservation_details_id);
		$criteria->compare('branch_has_menu_package_id',$this->branch_has_menu_package_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}